package com.yhh.college_information_platform.config;

import com.yhh.college_information_platform.utils.MinioProperties;
import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MinIO配置类
 *
 * @author yhh
 * @date 2025-10-25
 */
@Slf4j
@Configuration
public class MinioConfig {

    @Autowired
    private MinioProperties minioProperties;

    /**
     * 初始化MinIO客户端
     */
    @Bean
    public MinioClient minioClient() {
        log.info("初始化MinIO客户端，endpoint: {}, bucket: {}",
                minioProperties.getEndpoint(), minioProperties.getBucketName());

        return MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
                .build();
    }
}

